//
//  SegmentedItem.swift
//  cabbage_swift
//
//  Created by dfsx6 on 2022/1/14.
//

import UIKit

class SegmentedItem: NSObject {

    fileprivate var itemSize: CGSize {
        return CGSize.init(width: UIScreen.main.bounds.width, height: 50)
    }
}

extension SegmentedItem: BaseCollectionSectionProtocol {
    func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
        return itemSize
    }
    
    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        let cell = collectionView.exDequeueReusableCell(for: indexPath, cellType: SegmentedCollectionViewCell.self)!
        cell.contentWidth.constant = itemSize.width
        cell.contentHeight.constant = itemSize.height
        
        return cell
    }
    
    func registerForCollectionViewCell(_ collectionView: UICollectionView) {
        collectionView.exRegister(cell: SegmentedCollectionViewCell.self)
    }
    
    func numberOfItemsInSection(_ collectionView: UICollectionView) -> Int {
        return 1
    }
    
    func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
        let targetVC = SegmentedViewController.init()
        self.exTopVC?.navigationController?.pushViewController(targetVC, animated: true)
    }
}
